package com.util.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页数据返回对象
 *
 * @Author: tiancheng
 * @date: 2020/8/4 14:38
 */
@ApiModel("分页数据返回对象")
@Data
public class RPage<T> implements Serializable {
    private static final long serialVersionUID = -5171037347725994494L;
    
    @ApiModelProperty("消息")
    private String msg = RStatus.SUCCESS.getMessage();
    
    @ApiModelProperty("响应状态码")
    private int code = RStatus.SUCCESS.getValue();
    
    @ApiModelProperty("不分页情况下数据总数")
    private Integer total;
    
    @ApiModelProperty("查询条数")
    private Integer size;
    
    @ApiModelProperty("页数")
    private Integer current;
    
    @ApiModelProperty("是否存在上一页")
    private Boolean hasPrevious;
    
    @ApiModelProperty("是否存在下一页")
    private Boolean hasNext;
    
    @ApiModelProperty("分页数据")
    private List<T> data;
    

    
    public RPage<T> msg(String msg) {
        this.msg = msg;
        return this;
    }
    
    public RPage<T> code(int code) {
        this.code = code;
        return this;
    }
    

}
